
#include <scott/SChar.h>

BOOST_AUTO_TEST_SUITE( SChar_Test_Suite )

BOOST_AUTO_TEST_CASE( GetType_Test )
{
	SCharSp c = SChar::Create('A');
	BOOST_CHECK( c->GetType() == STypeChar );
}

BOOST_AUTO_TEST_CASE( GetAndSet_Test )
{
	SCharSp c = SChar::Create('A');
	BOOST_CHECK( c->Get() == 'A' );

	c->Set('B');
	BOOST_CHECK( c->Get() == 'B' );
}

BOOST_AUTO_TEST_CASE( ToString_Test )
{
	SCharSp c = SChar::Create('A');
	BOOST_CHECK( c->ToString() == "'A'" );
	BOOST_CHECK( c->ToString("n") == "A" );

	c->Set('\n');
	BOOST_CHECK( c->ToString() == "'\n'" );
	BOOST_CHECK( c->ToString("n") == "\n" );
}

BOOST_AUTO_TEST_CASE( SChar_Parse_Test )
{
	// Test
	BOOST_CHECK( SChar::Parse("' '")->Get() == ' ' );
	BOOST_CHECK( SChar::Parse("'A'")->Get() == 'A' );
	BOOST_CHECK( SChar::Parse("'9'")->Get() == '9' );

	BOOST_CHECK_THROW( SChar::Parse("''"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("'"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("'H"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("H'"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("'Hi'"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("blue"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("12"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("{}"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("{10}"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("{'A'}"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("{\"Hello\"}"), SParseException );
	BOOST_CHECK_THROW( SChar::Parse("{red}"), SParseException );
}

BOOST_AUTO_TEST_SUITE_END()
